package my.example.samplegridview;

import android.content.Context;
import android.os.CountDownTimer;
import android.util.AttributeSet;
import android.widget.TextView;

public class countdowntimer extends TextView {

	private CountDownTimer cdt;
	private countdowntimer _self;
	
	public countdowntimer(Context context, AttributeSet attrs) {
		super(context, attrs);
		_self = this;
	}
	
	public void startTimer(int remainingSeconds){
		cdt = new CountDownTimer(remainingSeconds, 1000) {

		     public void onTick(long millisUntilFinished) {
		    	 _self.setText("seconds remaining: " + millisUntilFinished / 1000);
		     }

		     public void onFinish() {
		    	 _self.setText("done!");
		    	 cdt.cancel();
		    	 //cdt = null;
		     }
		  }.start();
	}

}
